home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-06-18 | 6.9 KB | 343 lines | [TEXT/MPS ] |
- *******************************************************************************
- *
- InitTools PROC
- *
- * Description: Load and initialize the tools needed. Errors are detected
- * and FatalError is called if any occur. If there aren't any
- * errors, the list of menu templates is read and the menu-
- * bar is created.
- *
- *
- * Inputs: NONE
- *
- * Outputs: NONE
- *
- * External Refs:
- import FatalError
- *
- * Entry Points: NONE
- *
- *******************************************************************************
- with Globals
-
- ;
- ; Tool Direct page offsets here
- ;
- QDDPage equ $0000
- EMDPage equ QDDPage+$0300
- CtlDPage equ EMDPage+$0100
- MenuDPage equ CtlDPage+$0100
- LEDPage equ MenuDPage+$0100
- ToolDPSize equ LEDPage+$0100
-
- phk ; Save program bank register and
- plb ; load it as the data bank register
-
- tdc
- sta MyDP ; Save direct register
-
- _TLStartup ; Start Tool Locator
-
- pha ; Space for result
- _MMStartup ; Start memory manager
- PullWord MyID ; Save it for later use
-
- _MTStartup ; Start up Misc Tools
-
- _IMStartup ; Start integer math toolset
-
- PushLong #ToolTable ; Pointer to Tool table
- _LoadTools ; Load all RAM based tools
- bcc IT0005 ; Carry clear means no error
- brl FatalError ; Tools can't be loaded. Fatal error!
-
- IT0005
-
- ; Get memory for Tool Direct pages
-
- pha ; Room for result
- pha
- PushLong #ToolDPSize; Number of bytes needed
- PushWord MyID ; ID of this application
- PushWord #attrLocked+attrFixed+attrPage+attrBank
- PushLong #0 ; Allocate them in bank 0
- _NewHandle
- bcc IT0010 ; Test carry for error
- brl FatalError ; If no memory we got a fatal error!
-
- IT0010 PullLong DPHandle ; Retrieve handle to our DPage area
-
- lda [DPHandle] ; Dereference the handle to get a ptr
- sta DPPointer ; to our direct page area and save it.
-
- PushWord DPPointer ; QuickDraw uses 3 pages of Dpage
- PushWord #ScreenMode; Used to set all master SCB's
- PushWord #0 ; Zero means use default buf size
- PushWord MyID ; Application ID for allocating data
- _QDStartup ; Start QuickDraw, turn on SHR Screen
- bcc IT0015
- brl FatalError ; If it can't be started then bomb
-
- IT0015
- lda DPPointer ; Create address for Event Mgr DPage by
- clc ; loading in the pointer to the start
- adc #EMDPage ; of DPage and adding Evt Mgr offset.
- pha ; Now push it on the stack.
- PushWord #20 ; Size of event queue.
- PushWord #0 ; MouseClamp values.
- PushWord #ScreenWidth ; These will clamp mouse to screen
- PushWord #0 ; area only.
- PushWord #200
- PushWord MyID
- _EMStartup ; Start the event manager
- bcc IT0020
- brl FatalError ; Event manager is also a must
- IT0020
- PushWord MyID
- _WindStartup
- bcc IT0025
- brl FatalError
- IT0025
- PushWord MyID
- lda DPPointer
- clc
- adc #CtlDPage
- pha
- _CtlStartup
- bcc IT0030
- brl FatalError
- IT0030
-
- PushWord MyID
- lda DPPointer
- clc
- adc #MenuDPage
- pha
- _MenuStartUp
- bcc IT0035
- brl FatalError
- IT0035
- PushWord MyID
- lda DPPointer
- clc
- adc #LEDPage
- pha
- _LEStartUp
- bcc IT0040
- brl FatalError
- IT0040
- PushWord MyID
- _DialogStartup
- bcc IT0045
- brl FatalError
- IT0045
- _ListStartup
-
- _QDAuxStartup ; no error possible for this call
-
- _ScrapStartup ; No errors possible for this call
-
- _DeskStartup ; No error possible for this call
-
- ; insert application specific tools here
-
- PushLong #0
- _RefreshDeskTop
-
- RTS
-
- ToolTable dc.W 8 ; Data Block for LoadTools call
- dc.W 14,$0100 ; Window Manager
- dc.W 15,$0100 ; Menu Manager
- dc.W 16,$0100 ; Control Manager
- dc.W 18,$0100 ; QDAux
- dc.W 20,$0100 ; LineEdit tool set
- dc.W 21,$0100 ; Dialog Manager
- dc.W 22,$0100 ; Scrap manager
- dc.W 28,$0100 ; List Manager
-
- ENDP
-
- EJECT
- *******************************************************************************
- *
- FatalError PROC
- *
- * Description: Routine that is called whenever a tool sends back an error
- * that can not be recovered from. This routine prints the
- * error on the screen, waits for a keypress then quits back
- * to whoever started this application up!
- *
- *
- * Inputs: A = Error number
- *
- * Outputs: NONE (program exits)
- *
- * External Refs:
- import CloseTools
- *
- * Entry Points: NONE
- *
- *******************************************************************************
- with Globals
-
- pha ; Push the error code
- PushLong #ErrNumStr ; Address of storage area
- PushWord #4 ; Length of string
- _Int2Hex
-
- _GrafOff ; If QD Started, shut off graphics
-
- PushLong #ErrStr ; Write error message to the screen
- _WriteCString
-
- pha ; Space for result
- PushWord #0 ; No echo
- _ReadChar ; Wait for a key to be pressed
- pla ; Discard the key
-
- jsr CloseTools ; Shut down all the tools in case
- ; any got started up
-
- _Quit QuitParms ; Quit back to where we came from.
-
- brk $FF ; If the quit fails then just break
-
- ErrStr dc.B 'A fatal error has occured $'
- ErrNumStr dc.B 'xxxx press any key to exit',0
-
- ENDP
-
- EJECT
- *******************************************************************************
- *
- CloseTools PROC
- *
- * Description: Shut down the tools I started.
- *
- *
- * Inputs: NONE
- *
- * Outputs: NONE
- *
- * External Refs: NONE
- *
- * Entry Points: NONE
- *
- *******************************************************************************
- with Globals
-
- _ListShutdown
- _QDAuxShutDown
- _DeskShutDown
- _ScrapShutDown
- _DialogShutDown
- _LEShutDown
- _MenuShutDown
- _CtlShutDown
- _WindShutDown
- _EMShutDown
- _QDShutDown
- _MTShutDown
-
- PushLong DPHandle ; Dispose of all that DP memory
- _DisposeHandle
-
- PushWord MyID
- _MMShutDown
- _TLShutDown
-
- rts
- ENDP
-
- EJECT
- *******************************************************************************
- *
- DoAbout PROC
- *
- * Description: Bring up an Alert Dialog box with our name in it.
- *
- * Inputs: NONE
- *
- * Outputs: NONE
- *
- * External Refs: NONE
- *
- * Entry Points: NONE
- *
- *******************************************************************************
- With Globals
-
- pha ; space for result
- PushLong #AboutBox ; pointer to alert template
- PushLong #0 ; pointer to a filter proc (0=none)
- _NoteAlert
- pla ; get the item hit and dispose
-
- rts
-
- ; About Box alert template
- ; About Box alert template
-
- AboutBox
- atBoundsRect dc.W 30,30,100,290 ; for 320 use
- atAlertID dc.W 1 ; this is alert # 1
- atStage1 dc.B $80 ; draw for this stage
- atStage2 dc.B $81 ; draw for this stage
- atStage3 dc.B $82 ; draw for this stage
- atStage4 dc.B $83 ; draw for this stage
- atItem1 dc.L OKButton ; ok button for the alert
- atItem2 dc.L AboutTitle ; title of the program
- atItem3 dc.L AboutAut ; author
- atItem4 dc.L AboutCR ; version number string
- atItem5 dc.L AboutVers ; nill to end the list
- atEndList dc.L 0
-
- OKBTitle dc.B 2,'OK'
- OKButton
- dc.W 1
- dc.W 50,200,65,250
- dc.W $000A ; standard button
- dc.L OKBTitle
- dc.W 0
- dc.W 0 ; item flag
- dc.L 0 ; no color table
-
- AboutTitle
- dc.W 2
- dc.W 10,50,20,250
- dc.W $800F ; Stat Text
- dc.L TitleString
- dc.W 0
- dc.W 0 ; item flag
- dc.L 0 ; no color table
-
- AboutAut
- dc.W 3
- dc.W 22,50,32,250
- dc.W $800F ; Stat Text
- dc.L AutString
- dc.W 0
- dc.W 0 ; item flag
- dc.L 0 ; no color table
-
- AboutCR
- dc.W 4
- dc.W 34,50,46,250
- dc.W $800F ; Stat Text
- dc.L CRString
- dc.W 0
- dc.W 0 ; item flag
- dc.L 0 ; no color table
-
- AboutVers
- dc.W 5
- dc.W 48,50,60,250
- dc.W $800F ; Stat Text
- dc.L VersString
- dc.W 0
- dc.W 0 ; item flag
- dc.L 0 ; no color table
-
- ENDP
-